package com.vhall.component.service.sign.service.impl;


import com.vhall.component.dao.sign.SignRecordMapper;
import com.vhall.component.entity.sign.vo.SignRecordPageVO;
import com.vhall.component.service.sign.service.SignInnerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * 签到服务实现
 *
 * @author shenghua.luo
 */
@Slf4j
@Service
public class SignInnerServiceImpl implements SignInnerService {

    @Autowired
    private SignRecordMapper signRecordMapper;

    @Override
    public SignRecordPageVO<Integer> selectSignAfterLiveStart(String roomId, String startDateTime, int page, int pageSize, boolean queryAllCount) {
        int totalCount = 0;
        if (queryAllCount) {
            totalCount = signRecordMapper.selectSignAfterLiveStartCount(roomId, startDateTime);
        }
        List<Integer> signRecords = signRecordMapper.selectSignAfterLiveStart(roomId, startDateTime, (page - 1) * pageSize, pageSize);
        return new SignRecordPageVO<>(page, pageSize, totalCount, signRecords);
    }

    @Override
    public Integer countPartakeTotalAfterLiveStart(String roomId, String startDateTime) {
        return signRecordMapper.selectSignAfterLiveStartCount(roomId, startDateTime);
    }
}
